#include "FoodBuilderComboA.h"
#include "FoodHamburger.h"
#include "FoodDrinks.h"
#include "FoodChicken.h"

#include "UI/ModRun/Output/FactoryOutput.h"

//套餐A是 汉堡+饮料+炸鸡套餐;
FoodBuilderComboA::FoodBuilderComboA(QString HamburgerName, QString DrinkName, QString ChickName)
{
    m_strHamburgerName = HamburgerName;
    m_strDrinkName = DrinkName;
    m_strChickName = ChickName;
    m_listFood.clear();

    QString strOutput = "套餐A Builder 构造:" + m_strHamburgerName + m_strDrinkName + m_strChickName;
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}

FoodBuilderComboA::~FoodBuilderComboA()
{
    QString strOutput = "套餐A Builder 析构:" + m_strHamburgerName + m_strDrinkName + m_strChickName;
    qDebug() << strOutput;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutput };
        pOutPut->OutPut(outList);
    }
}

void FoodBuilderComboA::CreateFood(size_t uNum)
{
    QString strOutputStart = "套餐A Builder 创建Food开始: [" + QString::number(uNum) + "]";
    qDebug() << strOutputStart;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutputStart };
        pOutPut->OutPut(outList);
    }
    //////////////////////////////////////////////////////////////////////////
    for (size_t i = 0; i < uNum; i++)
    {
        std::shared_ptr<IFood> foodHamburger(new FoodHamburger(m_strHamburgerName));
        m_listFood.push_back(foodHamburger);
        std::shared_ptr<IFood> foodDrinks(new FoodDrinks(m_strDrinkName));
        m_listFood.push_back(foodDrinks);
        std::shared_ptr<IFood> foodClicken(new FoodChicken(m_strChickName));
        m_listFood.push_back(foodClicken);
    }
    ///////////////////////////////////////////////////////////////////////////////
    QString strOutputEnd = "套餐A Builder 创建Food结束: [" + QString::number(uNum) + "]";
    qDebug() << strOutputEnd;
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ strOutputEnd };
        pOutPut->OutPut(outList);
    }
}

std::list<std::shared_ptr<IFood>> FoodBuilderComboA::GetFoodItems()
{
    return m_listFood;
}
